#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 2e5+10;

int n,m,k,f[N],d[N];
struct link{int x,y;}t[N];
vector<int> op[N<<2];
vector<pii> s;

int gf(int x){while(f[x] ^ x) x = f[x];return x;}

void insert(int id,int xl,int xr,int o = 1,int l = 1,int r = k){
	if(xl == l && xr == r) return op[o].pb(id),void();
	int mid = l + r >> 1;
	if(xr <= mid) insert(id,xl,xr,o<<1,l,mid);
	else if(xl > mid) insert(id,xl,xr,o<<1|1,mid+1,r);
	else insert(id,xl,mid,o<<1,l,mid) , insert(id,mid+1,xr,o<<1|1,mid+1,r);
}

void merge(int x,int y){
	if(d[x] > d[y]) swap(x,y); if(x == y) return;
	s.pb(pii(x,d[x] == d[y])); d[y] += d[x] == d[y],f[x] = y;
}

void solve(int o = 1,int l = 1,int r = k){
	int nowcnt = s.size(); bool ok = 1;
	for(int x : op[o]){
		int u = t[x].x,v = t[x].y; u = gf(u),v = gf(v);
		if(u == v){for(int i = l;i <= r;i++) puts("No");ok = 0;break;}
		merge(gf(u+n),v); merge(gf(v+n),u);
	}
	if(ok){if(l == r) puts("Yes");else {int mid = l+r>>1; solve(o<<1,l,mid); solve(o<<1|1,mid+1,r);}}
	while(s.size() > nowcnt){pii x = s.back(); s.pop_back(); d[f[x.fi]] -= x.se; f[x.fi] = x.fi;}
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in,k = in;
	for(int i = 1,l,r;i <= m;i++){
		t[i].x = in,t[i].y = in;l = in+1,r = in;
		if(l <= r) insert(i,l,r);
	}for(int i = 1;i <= (n<<1);i++) f[i] = i;
	solve();
	return 0;
}

